// -*- coding: utf-8 -*- 
/**
 * Project: AlgorithmsLearn
 *
 * @author: yanking
 * Create time: 2022-04-10 10:48
 * IDE: IntelliJ IDEA
 * Introduction:
 */
package com.LeetCodeT.DateTrain;

import org.junit.jupiter.api.Test;

import java.util.HashSet;
import java.util.Set;

public class UniqueMorseRepresentations {
    /**
     * 独一无二的摩斯密码
     */
    public int uniqueMorseRepresentations(String[] words) {
        Set<String> translate = new HashSet<String>();
        String[] code = {".-", "-...", "-.-.", "-..", ".", "..-.", "--.", "....", "..", ".---", "-.-", ".-..", "--", "-.", "---", ".--.", "--.-", ".-.", "...", "-", "..-", "...-", ".--", "-..-", "-.--", "--.."};
        for (String word : words) {
            StringBuilder builder = new StringBuilder();
            for (char c : word.toCharArray()) {
                builder.append(code[c - 'a']);
            }
            translate.add(builder.toString());
        }
        return translate.size();
    }


    @Test
    public void shout() {
        String[] s = {"gin", "zen", "gig", "msg"};
        System.out.println(this.uniqueMorseRepresentations(s));
    }
}
